package com.ytjj.qmyx.admin.service.impl;

import com.github.pagehelper.PageHelper;
import com.ytjj.common.api.CommonPage;
import com.ytjj.qmyx.admin.dao.CopywriterConfigDao;
import com.ytjj.qmyx.admin.model.request.PageRequest;
import com.ytjj.qmyx.admin.service.CopywriterConfigService;
import com.ytjj.qmyx.mall.mapper.CopywriterConfigMapper;
import com.ytjj.qmyx.mall.model.CopywriterConfig;
import com.ytjj.qmyx.mall.model.CopywriterConfigExample;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class CopywriterConfigServiceImpl implements CopywriterConfigService {
    @Resource
    private CopywriterConfigDao copywriterConfigDao;
    @Override
    public CommonPage<CopywriterConfig> list(PageRequest pageRequest) {
        PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getPageSize());
        List<CopywriterConfig> copywriterConfigs = copywriterConfigDao.list();
        return CommonPage.restPage(copywriterConfigs);
    }

    @Override
    public Integer insert(CopywriterConfig copywriterConfig) {
        copywriterConfig.setCreateTime(new Date());
        int count = copywriterConfigDao.insertSelective(copywriterConfig);
        return count;
    }

    @Override
    public Integer update(CopywriterConfig copywriterConfig) {
        copywriterConfig.setUpdateTime(new Date());
        int count = copywriterConfigDao.update(copywriterConfig);
        return count;
    }
}
